// 定义医院列表相关的函数

// 引入axios实例
import { request } from '@utils/http'

// 引入ts类型
import {
  IhospitalListRes,
  IpcdList,
  IhospitalShowRes,
  IdepList,
  IscheduleRes,
  IscheduleDetailList,
} from './model/hospitalListTypes'
// 获取医院列表表格数据的函数
export const reqGetHospitalList = ({
  page,
  limit,
  hosname,
  hoscode,
  hostype,
  provinceCode,
  cityCode,
  districtCode,
  status,
}: any) =>
  request.get<any, IhospitalListRes>(`/admin/hosp/hospital/${page}/${limit}`, {
    params: {
      hosname,
      hoscode,
      hostype,
      provinceCode,
      cityCode,
      districtCode,
      status,
    },
  })

// 获取省数据的函数
export const reqGetProvince = (dictCode: string = 'province') =>
  request.get<any, IpcdList>(`/admin/cmn/dict/findByDictCode/${dictCode}`)
// 获取市和区
export const reqGetCityOrDistrict = (parentId: string) =>
  request.get<any, IpcdList>(`/admin/cmn/dict/findByParentId/${parentId}`)

// 获取医院详情数据
export const reqGetHospitalShow = (id: string) =>
  request.get<any, IhospitalShowRes>(`/admin/hosp/hospital/show/${id}`)

// 获取医院科室的数据
export const reqGetDepList = (hoscode: string) =>
  request.get<any, IdepList>(`/admin/hosp/department/${hoscode}`)

// 获取二级科室排班规则的函数
export const reqGetScheduleRules = (
  page: number,
  limit: number,
  hoscode: string,
  depcode: string
) =>
  request.get<any, IscheduleRes>(
    `/admin/hosp/schedule/getScheduleRule/${page}/${limit}/${hoscode}/${depcode}`
  )

// 获取排班详情数据的函数
export const reqGetScheduleDetail = (
  hoscode: string,
  depcode: string,
  workDate: string
) =>
  request.get<any, IscheduleDetailList>(
    `/admin/hosp/schedule/findScheduleList/${hoscode}/${depcode}/${workDate}`
  )
